//
// Created by Gorun on 2022/5/6.
//

#ifndef LOXPP_LOXCLASS_H
#define LOXPP_LOXCLASS_H

#include <any>
#include <memory>
#include <vector>
#include <string>
#include <map>

#include "LoxCallable.h"

using namespace std;

class Interpreter;
class LoxFunction;

class LoxClass: public LoxCallable, public enable_shared_from_this<LoxClass> {
private:
    map<string, shared_ptr<LoxFunction>> methods;
    const shared_ptr<LoxClass> superclass;

public:
    LoxClass(string name, shared_ptr<LoxClass> superclass, map<string, shared_ptr<LoxFunction>> methods);
    shared_ptr<LoxFunction> findMethod(string name);
    string toString() override;
    any call(Interpreter& interpreter, vector<any> arguments) override;
    int arity() override;
    const string name;
};

#endif //LOXPP_LOXCLASS_H
